using System;
using System.Collections;
using FireStarter.Base;
using FireStarterModeller.BO;
using Habanero.Base;
using Habanero.Base.Exceptions;
using Habanero.BO;
using Habanero.BO.ClassDefinition;
using Habanero.Util;
using NUnit.Framework;

namespace FireStarterModeller.Test.BO
{
    /// <summary>
    /// Provides a place to write custom tests for UIField objects.
    /// This file is only written once and can be changed.  The Def file
    /// attached to this as a dependent is rewritten with each regeneration
    /// and contains the standard tests for UIField.
    /// Regenerate this test project whenever there have been changes to the
    /// business objects.
    /// If tests are failing due to a unique setup in your application,
    /// you can either override the Create methods in TestUtils, or you
    /// can add the test to the ignore list below and reimplement it here.
    /// </summary>
    public partial class TestUIField
    {
        [TestFixtureSetUp]
        public void SetupTestFixture()
        {
            //------------------------------------------------------------
            // Use this list to ignore generated tests that are failing
            // due to a unique condition in your application.
            // Remember to reimplement the test here.
            //------------------------------------------------------------
            //_ignoreList.Add("TestMethodName", "Reason for ignoring it");
            base.SetupFixture();
        }

        [Test]
        public void Test_ToString()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsUIField.CreateUnsavedValidUIField();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(uiField.UIColumnLayout);
            Assert.IsNotNull(uiField.UIColumnLayout.UITab);
            Assert.IsNotNull(uiField.PropertyName);
            //---------------Execute Test ----------------------
            string actualToString = uiField.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(uiField.UIColumnLayout + " - " + uiField.PropertyName, actualToString);
        }

        [Test]
        public void Test_ToString_UIColumnLayoutNull()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsUIField.CreateUnsavedValidUIField();
            uiField.UIColumnLayout = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(uiField.UIColumnLayout);
            Assert.IsNotNull(uiField.PropertyName);
            //---------------Execute Test ----------------------
            string actualToString = uiField.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(uiField.PropertyName, actualToString);
        }

        [Test]
        public void Test_ToString_UIColumnLayoutNotNull_PropertyNull()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsUIField.CreateUnsavedValidUIField();
            uiField.PropertyName = null;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(uiField.UIColumnLayout);
            Assert.IsNull(uiField.PropertyName);
            //---------------Execute Test ----------------------
            string actualToString = uiField.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(uiField.UIColumnLayout + " - " + "Un-named Property", actualToString);
        }

        [Test]
        public void Test_ToString_WhenUIColumnLayoutIsNull_WhenPropertyIsNull_ShouldReturnUnnamedProperty()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsUIField.CreateUnsavedValidUIField();
            uiField.UIColumnLayout = null;
            uiField.PropertyName = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(uiField.UIColumnLayout);
            Assert.IsNull(uiField.PropertyName);
            //---------------Execute Test ----------------------
            string actualToString = uiField.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual("Un-named Property", actualToString);
        }

        [Test]
        public void Test_InsertNewUIField_Invalid()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();

            //---------------Assert Precondition----------------
            Assert.IsTrue(uiField.Status.IsNew);

            //---------------Execute Test ----------------------
            try
            {
                uiField.Save();
                Assert.Fail("expected Err");
            }
                //---------------Test Result -----------------------
            catch (BusObjectInAnInvalidStateException ex)
            {
                StringAssert.Contains
                    ("UIField.UI Control Type' is a compulsory field and has no value", ex.Message);
            }
            Assert.IsTrue(uiField.Status.IsNew);
        }

        [Test]
        public void Test_InsertNewUIField()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsUIField.CreateUnsavedValidUIField();

            //---------------Assert Precondition----------------
            Assert.IsTrue(uiField.Status.IsNew);

            //---------------Execute Test ----------------------
            uiField.Save();

            //---------------Test Result -----------------------
            Assert.IsFalse(uiField.Status.IsNew);
        }

        [Test]
        public void Test_IUIFormField_Editable_Get()
        {
            //---------------Set up test pack-------------------
            IUIFormField field = new UIField();
            ((UIField)field).Editable = false;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool returnedEditable = field.Editable;
           
            //---------------Test Result -----------------------
            Assert.IsFalse(returnedEditable);
        }

        [Test]
        public void Test_IUIFormField_Editable_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField field = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            field.Editable = false;
            //---------------Test Result -----------------------
            bool returnedEditable = field.Editable;
            Assert.IsFalse(returnedEditable);
        }

        [Test]
        public void Test_IUIFormField_ShowAsCompulsory_Get()
        {
            //---------------Set up test pack-------------------
            IUIFormField field = new UIField();
            ((UIField)field).ShowAsCompulsory = false;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool? returnedShowAsCompulsory = field.ShowAsCompulsory;
            //---------------Test Result -----------------------
            Assert.IsFalse(returnedShowAsCompulsory.GetValueOrDefault());
        }

        [Test]
        public void Test_IUIFormField_ShowAsCompulsory_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField field = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            field.ShowAsCompulsory = false;
            //---------------Test Result -----------------------
            bool? returnedShowAsCompulsory = field.ShowAsCompulsory;
            Assert.IsFalse(returnedShowAsCompulsory.GetValueOrDefault());
        }

        [Test]
        public void Test_IUIFormField_ControlAssemblyName_Get()
        {
            //---------------Set up test pack-------------------
            UIControlType controlType = TestUtilsShared.CreateUnsavedValidUIControlTypeInfo();
            IUIFormField formField = new UIField();
            ((UIField)formField).UIControlType = controlType;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            string returnedControlAssemblyName = formField.ControlAssemblyName;
            //---------------Test Result -----------------------
            Assert.AreEqual(controlType.AssemblyName, returnedControlAssemblyName);
        }

        [Test]
        public void Test_IUIFormField_ControlAssemblyName_Get_NoUIGridColumnControlType()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            string returnedControlAssemblyName = formField.ControlAssemblyName;
            //---------------Test Result -----------------------
            Assert.AreEqual("", returnedControlAssemblyName);
        }

        [Test]
        public void Test_IUIFormField_ControlAssemblyName_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            try
            {
                formField.ControlAssemblyName = TestUtilsShared.GetRandomString();
                Assert.Fail("Expected to throw an NotImplementedException");
            }
            //---------------Test Result -----------------------
            catch (NotImplementedException ex)
            {
                StringAssert.Contains("This should be set when the UIControlType is set for the UIField.", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_ControlTypeName_Get()
        {
            //---------------Set up test pack-------------------
            UIControlType controlType = TestUtilsShared.CreateUnsavedValidUIControlTypeInfo();
            IUIFormField formField = new UIField();
            ((UIField)formField).UIControlType = controlType;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            string returnedControlTypeName = formField.ControlTypeName;
            //---------------Test Result -----------------------
            Assert.AreEqual(controlType.TypeName, returnedControlTypeName);
        }

        [Test]
        public void Test_IUIFormField_ControlTypeName_Get_NoUIColumnControlType()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            string returnedControlTypeName = formField.ControlTypeName;
            //---------------Test Result -----------------------
            Assert.AreEqual("", returnedControlTypeName);
        }

        [Test]
        public void Testt_IUIFormField_ControlTypeName_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlType);
            //---------------Execute Test ----------------------
            try
            {
                formField.ControlTypeName = TestUtilsShared.GetRandomString();
                Assert.Fail("Expected to throw an NotImplementedException");
            }
            //---------------Test Result -----------------------
            catch (NotImplementedException ex)
            {
                StringAssert.Contains(
                    "This should be set when the UIControlType is set for the UIField.", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_ControlType_Get()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            DMSolution solution = (DMSolution) uiField.UIColumnLayout.UITab.UIFormInfo.UIView.Class.Solution;
            UIControlType controlType = solution.GetUIFormFieldControlType("System.Windows.Forms",
                                                                    "TextBox");
            uiField.UIControlType = controlType;
            IUIFormField formField = uiField;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(uiField.UIControlType);
            //---------------Execute Test ----------------------
            Type returnedControlType = formField.ControlType;
            //---------------Test Result -----------------------
            Assert.AreEqual(controlType.AssemblyName + "." + controlType.TypeName, returnedControlType.ToString());
        }

        [Test]
        public void Test_IUIFormField_ControlType_Get_NoControlType()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------
            Assert.IsNull(uiField.UIControlType);
            //---------------Execute Test ----------------------
            Type returnedControlType = formField.ControlType;
            //---------------Test Result -----------------------
            Assert.IsNull(returnedControlType);
        }

        [Test]
        public void Test_IUIFormField_ControlType_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.ControlType = TypeLoader.LoadType("System.Windows.Forms", "TextBox");
                Assert.Fail("Expected to throw an ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (NotImplementedException ex)
            {
                StringAssert.Contains("Please set this via the UIControlType relationship.", ex.Message);
            }
        }



        [Test]
        public void Test_IUIFormField_Parameters_NoParameters()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Hashtable returnedParameters = formField.Parameters;
            //---------------Test Result -----------------------
            BusinessObjectCollection<UIParameter> parameters = ((UIField)formField).UIParameters;
            Assert.AreEqual(parameters.Count, returnedParameters.Count);

            foreach (UIParameter parameter in parameters)
            {
                Assert.IsTrue(returnedParameters.ContainsKey(parameter.Name));
                Assert.IsTrue(returnedParameters.ContainsValue(parameter.Value));
            }
        }

        [Test]
        public void Test_IUIFormField_Parameters()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            UIParameter uiParameter = uiField.UIParameters.CreateBusinessObject();
            TestUtilsShared.UpdateUIParameterInfoWithValidData(uiParameter);
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------
            Assert.AreEqual(1, uiField.UIParameters.Count);
            //---------------Execute Test ----------------------
            Hashtable returnedParameters = formField.Parameters;
            //---------------Test Result -----------------------
            BusinessObjectCollection<UIParameter> parameters = uiField.UIParameters;
            Assert.AreEqual(parameters.Count, returnedParameters.Count);

            foreach (UIParameter parameter in parameters)
            {
                Assert.IsTrue(returnedParameters.ContainsKey(parameter.Name));
                Assert.IsTrue(returnedParameters.ContainsValue(parameter.Value));
            }
        }

        [Test]
        public void Test_IUIFormField_GetParameterValue()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            UIParameter uiParameter = uiField.UIParameters.CreateBusinessObject();
            TestUtilsShared.UpdateUIParameterInfoWithValidData(uiParameter);
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object returnedParameterValue = formField.GetParameterValue(uiParameter.Name);
            //---------------Test Result -----------------------
            Assert.AreEqual(uiParameter.Value, returnedParameterValue);
        }

        [Test]
        public void Test_IUIFormField_GetParameterValue_ParameterDoesNotExist()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            string parameterName = TestUtilsShared.GetRandomString();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.GetParameterValue(parameterName);
                Assert.Fail("Expected to throw an ArgumentException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentException ex)
            {
                StringAssert.Contains("parameterName", ex.ParamName);
                StringAssert.Contains("There is no parameter with the name '" + parameterName + "' for the UIField", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_GetParameterValue_NoParameter()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.GetParameterValue(null);
                Assert.Fail("Expected to throw an ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("parameterName", ex.ParamName);
                StringAssert.Contains("Value cannot be null", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_HasParameterValue()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            UIParameter uiParameter = uiField.UIParameters.CreateBusinessObject();
            TestUtilsShared.UpdateUIParameterInfoWithValidData(uiParameter);
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------
            Assert.IsTrue(uiField.UIParameters.Contains(uiParameter));
            //---------------Execute Test ----------------------
            bool hasParameterValue = formField.HasParameterValue(uiParameter.Name);
            //---------------Test Result -----------------------
            Assert.IsTrue(hasParameterValue);
        }


        [Test]
        public void Test_IUIFormField_HasParameterValue_NoParameter()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.HasParameterValue(null);
                Assert.Fail("Expected to throw an ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("parameterName", ex.ParamName);
                StringAssert.Contains("Value cannot be null", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_HasParameterValue_ParameterDoesNotExist()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            string parameterName = TestUtilsShared.GetRandomString();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.GetParameterValue(parameterName);
                Assert.Fail("Expected to throw an ArgumentException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentException ex)
            {
                StringAssert.Contains("parameterName", ex.ParamName);
                StringAssert.Contains("There is no parameter with the name '" + parameterName + "' for the UIField", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_GetLabel()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            string heading = TestUtilsShared.GetRandomString();
            ((UIField)formField).LabelText = heading;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string returnedHeading = formField.GetLabel();
            //---------------Test Result -----------------------
            Assert.AreEqual(heading, returnedHeading);
        }


        [Test]
        public void Test_IUIFormField_MapperAssembly_Get()
        {
            //---------------Set up test pack-------------------
            UIControlMapperType controlMapperType = TestUtilsShared.CreateUnsavedValidUIControlMapperTypeInfo();
            IUIFormField formField = new UIField();
            ((UIField)formField).UIControlMapperType = controlMapperType;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(((UIField)formField).UIControlMapperType);
            //---------------Execute Test ----------------------
            string returnedMapperAssembly = formField.MapperAssembly;
            //---------------Test Result -----------------------
            Assert.AreEqual(controlMapperType.AssemblyName, returnedMapperAssembly);
        }

        [Test]
        public void Test_IUIFormField_MapperAssembly_Get_NoUIControlMapperType()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlMapperType);
            //---------------Execute Test ----------------------
            string returnedMapperAssembly = formField.MapperAssembly;
            //---------------Test Result -----------------------
            Assert.AreEqual("", returnedMapperAssembly);
        }

        [Test]
        public void Test_IUIFormField_MapperTypeName_Get()
        {
            //---------------Set up test pack-------------------
            UIControlMapperType controlMapperType = TestUtilsShared.CreateUnsavedValidUIControlMapperTypeInfo();
            IUIFormField formField = new UIField();
            ((UIField)formField).UIControlMapperType = controlMapperType;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(((UIField)formField).UIControlMapperType);
            //---------------Execute Test ----------------------
            string returnedMapperTypeName = formField.MapperTypeName;
            //---------------Test Result -----------------------
            Assert.AreEqual(controlMapperType.TypeName, returnedMapperTypeName);
        }

        [Test]
        public void Test_IUIFormField_MapperTypeName_Get_NoUIControlMapperType()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------
            Assert.IsNull(((UIField)formField).UIControlMapperType);
            //---------------Execute Test ----------------------
            string returnedMapperTypeName = formField.MapperTypeName;
            //---------------Test Result -----------------------
            Assert.AreEqual("", returnedMapperTypeName);
        }

        [Test]
        public void Testt_IUIFormField_MapperTypeName_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField(); ;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                formField.MapperTypeName = TestUtilsShared.GetRandomString();
                Assert.Fail("Expected to throw an NotImplementedException");
            }
            //---------------Test Result -----------------------
            catch (NotImplementedException ex)
            {
                StringAssert.Contains(
                    "This should be set when the UIControlMapperType is set for the UIField.", ex.Message);
            }
        }


        [Test]
        public void Test_IUIFormField_ToolTipText()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            string toolTipText = TestUtilsShared.GetRandomString();
            uiField.ToolTipText = toolTipText;
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------
            Assert.AreEqual(toolTipText, uiField.ToolTipText);
            //---------------Execute Test ----------------------
            string returnedToolTipText = formField.ToolTipText;
            //---------------Test Result -----------------------
            Assert.AreEqual(toolTipText, returnedToolTipText);
        }

        [Test]
        public void Test_IUIFormField_IsCompulsory()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            IDMProperty property = uiField.GetDMProperty();
            IUIFormField formField = uiField;
            DMProperty dmProperty = (DMProperty) property;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dmProperty);
            //---------------Execute Test ----------------------
            bool isCompulsory = formField.IsCompulsory;
            //---------------Test Result -----------------------
            Assert.AreEqual(dmProperty.Compulsory, isCompulsory);
        }
        
        [Test]
        public void Test_IUIFormField_IsCompulsory_NoProperty()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            uiField.PropertyName = null;
            IUIFormField formField = uiField;

            //---------------Assert Precondition----------------
            Assert.IsNull(uiField.PropertyName);
            //---------------Execute Test ----------------------
            bool isCompulsory = formField.IsCompulsory;
            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory);
        }

        [Test]
        public void Test_IUIFormField_UIFormColumn_Get()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            UIColumnLayout columnLayout = uiField.UIColumnLayout;
            IUIFormField formField = uiField;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(columnLayout);
            //---------------Execute Test ----------------------
            IUIFormColumn formColumn = formField.UIFormColumn;
            //---------------Test Result -----------------------
            Assert.AreSame(columnLayout, formColumn);
        }

        [Test]
        public void Test_IUIFormField_UIFormColumn_Get_NoColumnLayout()
        {
            //---------------Set up test pack-------------------
            UIField uiField = new UIField();
            IUIFormField formField = uiField;
            //---------------Assert Precondition----------------
            Assert.IsNull(uiField.UIColumnLayout);
            //---------------Execute Test ----------------------
            IUIFormColumn formColumn = formField.UIFormColumn;
            //---------------Test Result -----------------------
            Assert.IsNull(formColumn);
        }


        [Test]
        public void Test_IUIFormField__UIFormColumn_Set()
        {
            //---------------Set up test pack-------------------
            IUIFormField formField = new UIField();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                formField.UIFormColumn = new UIFormColumn();
                Assert.Fail("Expected to throw an NotImplementedException");
            }
            //---------------Test Result -----------------------
            catch (NotImplementedException ex)
            {
                StringAssert.Contains("This should be set via the UIColumnLayout relationship.", ex.Message);
            }
        }

        [Test]
        public void Test_IUIFormField_Label_Get()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            IUIFormField formField = uiField;
            
            //---------------Assert Precondition----------------
            Assert.Greater(uiField.LabelText.Length, 0);
            //---------------Execute Test ----------------------
            string label = formField.Label;
            //---------------Test Result -----------------------
            Assert.AreEqual(uiField.LabelText, label);
        }

        [Test]
        public void Test_IUIFormField_Label_Set()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            IUIFormField formField = uiField;
            string newLabel = TestUtilsShared.GetRandomString();
            
            //---------------Assert Precondition----------------
            Assert.AreNotEqual(newLabel, uiField.LabelText);
            //---------------Execute Test ----------------------
            formField.Label = newLabel;
            //---------------Test Result -----------------------
            Assert.AreEqual(newLabel, uiField.LabelText);
        }

        [Test]
        public void Test_IUIFormField_Layout_Get()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            const string groupbox = "GroupBox";
            uiField.Layout = groupbox;
            IUIFormField formField = uiField;

            //---------------Assert Precondition----------------
            Assert.AreEqual(groupbox, uiField.Layout);
            //---------------Execute Test ----------------------
            LayoutStyle layout = formField.Layout;
            //---------------Test Result -----------------------
            Assert.AreEqual(uiField.Layout, layout.ToString());
        }

        [Test]
        public void Test_IUIFormField_Layout_Set()
        {
            //---------------Set up test pack-------------------
            UIField uiField = TestUtilsShared.CreateUnsavedValidUIField();
            IUIFormField formField = uiField;

            //---------------Assert Precondition----------------
            Assert.AreNotEqual(LayoutStyle.GroupBox.ToString(), uiField.Layout);
            //---------------Execute Test ----------------------
            formField.Layout = LayoutStyle.GroupBox;
            //---------------Test Result -----------------------
            Assert.AreSame(LayoutStyle.GroupBox.ToString(), uiField.Layout);
        }
        [Test]
        public void Test_GetParent()
        {
            //---------------Set up test pack-------------------
            UIColumnLayout view = new UIColumnLayout();
            UIField formInfo = new UIField();
            view.UIFields.Add(formInfo);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IModelElement parent = ((IModelElement)formInfo).Parent;
            //---------------Test Result -----------------------
            Assert.AreSame(view, parent);
        }

        [Test]
        public void Test_SetParentExceptionThrown()
        {
            //---------------Set up test pack-------------------
            IModelElement prop = new UIField();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Exception exceptionThrown = null;
            try
            {
                prop.Parent = new UIColumnLayout();
            }
            catch (Exception ex)
            {
                exceptionThrown = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exceptionThrown);
            Assert.IsInstanceOf(typeof(HabaneroDeveloperException), exceptionThrown);
            StringAssert.Contains
                ("Set the parent of the UIField by setting the related UIColumnLayout object", exceptionThrown.Message);
        }

        [Test]
        public void TestGetProperty()
        {
            //---------------Set up test pack-------------------
            UIField field = TestUtilsShared.CreateUnsavedValidUIField();
            DMProperty dmProperty = TestUtilsShared.CreateUnsavedValidDMProperty(field.UIColumnLayout.UITab.UIFormInfo.UIView.Class);

            field.PropertyName = dmProperty.PropertyName;

            //---------------Assert PreConditions---------------            
            //---------------Execute Test ----------------------
            IDMProperty fieldProperty = field.GetDMProperty();
            //---------------Test Result -----------------------
            Assert.That(fieldProperty, Is.SameAs(dmProperty));

            //---------------Tear Down -------------------------          
        }
    }
}